home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / utils / ab2ascii-1.3 / xtok.c < prev   
C/C++ Source or Header  |  1996-09-11  |  1KB  |  70 lines

  1. /*
  2.    Extract the token table out of the AmigaBASIC Editor (if available on stdin)
  3.    We need AmigaBASIC Version 1.3 as of 6 Oct 1986
  4.    hacked by Tobias Ferber 1994.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. /* let's roll */
  10.  
  11. int main(int argc, char **argv)
  12. {
  13.   int c,x='A';
  14.  
  15.   fseek(stdin, 0xBEB4, 0L);  /* beginning of the token table(s) */
  16.  
  17.   if( ftell(stdin) != 0xBEB4 )
  18.   {
  19.     fprintf(stderr,"usage: %s < [AmigaBASIC Editor]\n",*argv);
  20.     exit(10);
  21.   }
  22.  
  23.   printf("; AmigaBASIC Token table\n\n");
  24.  
  25.   getchar();
  26.  
  27.   do {
  28.  
  29.     c= getchar();
  30.  
  31.     if(c == 0x00) do {
  32.       ++x;
  33.       c= getchar();
  34.  
  35.     } while( c == 0x00 );
  36.  
  37.     printf("  \"%c",x);
  38.     ungetc(c,stdin);
  39.  
  40.     do {
  41.  
  42.       c= getchar();
  43.  
  44.       if(c < 0x80)
  45.         putchar(c);
  46.       else
  47.         ungetc(c,stdin);
  48.  
  49.     } while( c < 0x80 && !feof(stdin) );
  50.  
  51.  
  52.     printf("\"\t0x");
  53.  
  54.     do {
  55.       c= getchar();
  56.  
  57.       if(c >= 0x80)
  58.         printf("%02x",c);
  59.       else
  60.         ungetc(c,stdin);
  61.  
  62.     } while( c > 0x80 && !feof(stdin) );
  63.  
  64.     printf("\n");
  65.  
  66.   } while( !feof(stdin) && x <= 'Z' );
  67.  
  68.   exit(0);
  69. }
  70.